<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<meta name="description" content="">
<meta name="author" content="">

<title>订单列表</title>

<!-- Bootstrap core CSS -->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="<%=basePath%>css/designer.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

<script src="<%=basePath%>js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#catalogId").change(function(){
			$("#searchForm1").submit();
		});
	})
	
	function addToCar(pid) {
		window.showModalDialog("/designer/addToCar?pid=" + pid, "", "dialogWidth:550px; dialogHeight:500px; status:0; help:0");
	}
</script>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="panel panel-primary">
        <div class="panel-heading">检索条件</div>
        <div class="panel-body">
          <form id="orderForm" action="/designer/listOrder" method="post">
            <div class="form-horizontal">
              <div class="form-group">
                <label class="col-md-1 control-label">订单编号</label>
                <div class="col-md-2">
                  <input type="text" class="input-sm form-control" name="oid" value="${oid }">
                </div>
                <label class="col-md-1 control-label">订单状态</label>
                <div class="col-md-2">
                  <select name="status" class="form-control">
                    <c:forEach items="${orderStatusList }" var="orderStatus" varStatus="s">
                      <c:if test="${orderStatus.id == status }">
                        <option value="${orderStatus.id }" selected="selected">${orderStatus.name }</option>
                      </c:if>
                      <c:if test="${orderStatus.id != status }">
                        <option value="${orderStatus.id }">${orderStatus.name }</option>
                      </c:if>
                    </c:forEach>
                  </select>
                </div>
                <div class="col-md-2 col-md-offset-2">
                  <button type="submit" class="btn btn-success">
                    <span class="glyphicon glyphicon-search"></span>&nbsp;查询
                  </button>
                </div>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
    <jsp:useBean id="planList" class="com.xlf.cache.PlanList"></jsp:useBean>
    <jsp:useBean id="orderStatusList" class="com.xlf.cache.OrderStatusList"></jsp:useBean>
    <div class="row">
      <div class="panel panel-primary">
        <div class="panel-heading">订单列表</div>
        <div class="panel-body">
          <table class="table table-bordered table-striped">
            <thead>
              <tr>
                <th>订单号</th>
                <th>客户姓名</th>
                <th>客户地址</th>
                <th>设计师</th>
                <th>套餐类型</th>
                <th>订单价格</th>
                <td>创建时间</td>
                <th>订单状态</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach items="${pageRecord.list }" var="order" varStatus="s">
                <tr>
                  <td>${order.o_id }</td>
                  <td>${order.custerName }</td>
                  <td>${order.custerAddress }</td>
                  <td>${order.designerName }</td>
                  <td>${planList.getName(order.planType) }</td>
                  <td>${order.price }</td>
                  <td><fmt:formatDate value="${order.createTime}" type="date"/></td>
                  <td>${orderStatusList.getName(order.status) }</td>
                  <td>
                    <a class="btn btn-sm btn-primary" href="/designer/viewOrder?oid=${order.o_id }">
                      <span class="glyphicon glyphicon-eye-open"></span>&nbsp;详细
                    </a>&nbsp;&nbsp;
                    <!--  
                    <c:if test="${order.status == 0 }">
                      <a class="btn btn-sm btn-danger" href="/designer/deleteOrder?oid=${order.o_id }" onclick="return confirm('确认撤销此订单?');">
                        <span class="glyphicon glyphicon-trash"></span>&nbsp;撤销
                      </a>
                    </c:if>
                    -->
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-2 col-md-offset-5">
        共 ${pageRecord.totalRow } 条记录&nbsp;&nbsp;${pageRecord.pageNumber }/${pageRecord.totalPage }页
      </div>
      <div class="col-md-2 col-md-offset-3">
        <nav>
          <ul class="pagination">
            <c:if test="${pageRecord.totalPage <= 10 }">
              <c:set var="maxPage" value="${pageRecord.totalPage }"></c:set>
            </c:if>
            <c:if test="${pageRecord.totalPage > 10 }">
              <c:set var="maxPage" value="10"></c:set>
            </c:if>
            <c:forEach begin="1" end="${maxPage }" varStatus="s">
              <li><a href="/designer/listOrder?status=${status }&page=${s.index }">${s.index }</a></li>  
            </c:forEach>
          </ul>
        </nav>
      </div>
    </div>
    <div class="row">
      <div class="col-md-2 col-md-offset-5">
        <a class="btn btn-lg btn-block btn-default" href="/designer/plan" ><span class="glyphicon glyphicon-home" style="padding-right:10px;"></span>返回首页</a>
      </div>
    </div>
  </div>
  <!-- /container -->

  <c:if test="${deleteNotice != null }">
  <script type="text/javascript">
  	alert('${deleteNotice}');		
  </script>
  </c:if>
</body>

</html>